local UI = SecretaryUI

local SliderButton_OnClick = function (self)
	local p = self:GetParent()
	
	p:GetParent().object:OnSliderButton_Click(p:GetOrientation(), self.type)
end

local function CreateSliderButton(parent, type, handler)
	local button = CreateFrame("Button", nil, parent)
	
	local CreateTexture = UI.CreateTexture
	button:SetNormalTexture(CreateTexture(button, "Interface\\Buttons\\UI-ScrollBar-Scroll"..type.."Button-Up"))
	button:SetPushedTexture(CreateTexture(button, "Interface\\Buttons\\UI-ScrollBar-Scroll"..type.."Button-Down"))
	button:SetDisabledTexture(CreateTexture(button, "Interface\\Buttons\\UI-ScrollBar-Scroll"..type.."Button-Disabled"))
	button:SetHighlightTexture(CreateTexture(button, "Interface\\Buttons\\UI-ScrollBar-Scroll"..type.."Button-Highlight", "ADD"))
	
	button:SetWidth(16)
	button:SetHeight(16)
	button.type = type
	button:SetScript("OnClick", SliderButton_OnClick)
	
	return button
end

local function CreateSlider(parent, vertical)
	local slider = CreateFrame("Slider", nil, parent)
	
	if vertical then
		slider:SetOrientation("VERTICAL")
		slider:SetWidth(16)
		slider.prev = CreateSliderButton(slider, "Up")
		slider.next = CreateSliderButton(slider, "Down")
	else
		slider:SetOrientation("HORIZONTAL")
		slider:SetHeight(16)
		slider.prev = CreateSliderButton(slider, "Left")
		slider.next = CreateSliderButton(slider, "Right")
	end
	
	local thumb = slider:CreateTexture()
	thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
	thumb:SetWidth(16)
	thumb:SetHeight(16)
	slider:SetThumbTexture(thumb)
	
	return slider
end

UI.CreateSliderButton = CreateSliderButton
UI.CreateSlider = CreateSlider

